<?php


abstract class BaseFuncionarios extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $nome = 'null';


	
	protected $endereco = 'null';


	
	protected $num = 'null';


	
	protected $compl;


	
	protected $bairro = 'null';


	
	protected $cidade_id = 0;


	
	protected $estado_id = 0;


	
	protected $cep;


	
	protected $tel_res;


	
	protected $tel_com;


	
	protected $tel_cel;


	
	protected $email;


	
	protected $rg;


	
	protected $cpf;


	
	protected $credencial_id = 0;


	
	protected $ativo = 1;


	
	protected $created_at;


	
	protected $updated_at;


	
	protected $usuario_id;

	
	protected $aCidades;

	
	protected $aEstados;

	
	protected $aCredencials;

	
	protected $aUsuarios;

	
	protected $collCobradorss;

	
	protected $lastCobradorsCriteria = null;

	
	protected $collUsuarioss;

	
	protected $lastUsuariosCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getNome()
	{

		return $this->nome;
	}

	
	public function getEndereco()
	{

		return $this->endereco;
	}

	
	public function getNum()
	{

		return $this->num;
	}

	
	public function getCompl()
	{

		return $this->compl;
	}

	
	public function getBairro()
	{

		return $this->bairro;
	}

	
	public function getCidadeId()
	{

		return $this->cidade_id;
	}

	
	public function getEstadoId()
	{

		return $this->estado_id;
	}

	
	public function getCep()
	{

		return $this->cep;
	}

	
	public function getTelRes()
	{

		return $this->tel_res;
	}

	
	public function getTelCom()
	{

		return $this->tel_com;
	}

	
	public function getTelCel()
	{

		return $this->tel_cel;
	}

	
	public function getEmail()
	{

		return $this->email;
	}

	
	public function getRg()
	{

		return $this->rg;
	}

	
	public function getCpf()
	{

		return $this->cpf;
	}

	
	public function getCredencialId()
	{

		return $this->credencial_id;
	}

	
	public function getAtivo()
	{

		return $this->ativo;
	}

	
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
						$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getUpdatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->updated_at === null || $this->updated_at === '') {
			return null;
		} elseif (!is_int($this->updated_at)) {
						$ts = strtotime($this->updated_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
			}
		} else {
			$ts = $this->updated_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getUsuarioId()
	{

		return $this->usuario_id;
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = FuncionariosPeer::ID;
		}

	} 
	
	public function setNome($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nome !== $v || $v === 'null') {
			$this->nome = $v;
			$this->modifiedColumns[] = FuncionariosPeer::NOME;
		}

	} 
	
	public function setEndereco($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->endereco !== $v || $v === 'null') {
			$this->endereco = $v;
			$this->modifiedColumns[] = FuncionariosPeer::ENDERECO;
		}

	} 
	
	public function setNum($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->num !== $v || $v === 'null') {
			$this->num = $v;
			$this->modifiedColumns[] = FuncionariosPeer::NUM;
		}

	} 
	
	public function setCompl($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->compl !== $v) {
			$this->compl = $v;
			$this->modifiedColumns[] = FuncionariosPeer::COMPL;
		}

	} 
	
	public function setBairro($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->bairro !== $v || $v === 'null') {
			$this->bairro = $v;
			$this->modifiedColumns[] = FuncionariosPeer::BAIRRO;
		}

	} 
	
	public function setCidadeId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->cidade_id !== $v || $v === 0) {
			$this->cidade_id = $v;
			$this->modifiedColumns[] = FuncionariosPeer::CIDADE_ID;
		}

		if ($this->aCidades !== null && $this->aCidades->getId() !== $v) {
			$this->aCidades = null;
		}

	} 
	
	public function setEstadoId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->estado_id !== $v || $v === 0) {
			$this->estado_id = $v;
			$this->modifiedColumns[] = FuncionariosPeer::ESTADO_ID;
		}

		if ($this->aEstados !== null && $this->aEstados->getId() !== $v) {
			$this->aEstados = null;
		}

	} 
	
	public function setCep($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cep !== $v) {
			$this->cep = $v;
			$this->modifiedColumns[] = FuncionariosPeer::CEP;
		}

	} 
	
	public function setTelRes($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->tel_res !== $v) {
			$this->tel_res = $v;
			$this->modifiedColumns[] = FuncionariosPeer::TEL_RES;
		}

	} 
	
	public function setTelCom($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->tel_com !== $v) {
			$this->tel_com = $v;
			$this->modifiedColumns[] = FuncionariosPeer::TEL_COM;
		}

	} 
	
	public function setTelCel($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->tel_cel !== $v) {
			$this->tel_cel = $v;
			$this->modifiedColumns[] = FuncionariosPeer::TEL_CEL;
		}

	} 
	
	public function setEmail($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = FuncionariosPeer::EMAIL;
		}

	} 
	
	public function setRg($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->rg !== $v) {
			$this->rg = $v;
			$this->modifiedColumns[] = FuncionariosPeer::RG;
		}

	} 
	
	public function setCpf($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cpf !== $v) {
			$this->cpf = $v;
			$this->modifiedColumns[] = FuncionariosPeer::CPF;
		}

	} 
	
	public function setCredencialId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->credencial_id !== $v || $v === 0) {
			$this->credencial_id = $v;
			$this->modifiedColumns[] = FuncionariosPeer::CREDENCIAL_ID;
		}

		if ($this->aCredencials !== null && $this->aCredencials->getId() !== $v) {
			$this->aCredencials = null;
		}

	} 
	
	public function setAtivo($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->ativo !== $v || $v === 1) {
			$this->ativo = $v;
			$this->modifiedColumns[] = FuncionariosPeer::ATIVO;
		}

	} 
	
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = FuncionariosPeer::CREATED_AT;
		}

	} 
	
	public function setUpdatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->updated_at !== $ts) {
			$this->updated_at = $ts;
			$this->modifiedColumns[] = FuncionariosPeer::UPDATED_AT;
		}

	} 
	
	public function setUsuarioId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->usuario_id !== $v) {
			$this->usuario_id = $v;
			$this->modifiedColumns[] = FuncionariosPeer::USUARIO_ID;
		}

		if ($this->aUsuarios !== null && $this->aUsuarios->getId() !== $v) {
			$this->aUsuarios = null;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->nome = $rs->getString($startcol + 1);

			$this->endereco = $rs->getString($startcol + 2);

			$this->num = $rs->getString($startcol + 3);

			$this->compl = $rs->getString($startcol + 4);

			$this->bairro = $rs->getString($startcol + 5);

			$this->cidade_id = $rs->getInt($startcol + 6);

			$this->estado_id = $rs->getInt($startcol + 7);

			$this->cep = $rs->getString($startcol + 8);

			$this->tel_res = $rs->getString($startcol + 9);

			$this->tel_com = $rs->getString($startcol + 10);

			$this->tel_cel = $rs->getString($startcol + 11);

			$this->email = $rs->getString($startcol + 12);

			$this->rg = $rs->getString($startcol + 13);

			$this->cpf = $rs->getString($startcol + 14);

			$this->credencial_id = $rs->getInt($startcol + 15);

			$this->ativo = $rs->getInt($startcol + 16);

			$this->created_at = $rs->getTimestamp($startcol + 17, null);

			$this->updated_at = $rs->getTimestamp($startcol + 18, null);

			$this->usuario_id = $rs->getInt($startcol + 19);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 20; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Funcionarios object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(FuncionariosPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			FuncionariosPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
    if ($this->isNew() && !$this->isColumnModified(FuncionariosPeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

    if ($this->isModified() && !$this->isColumnModified(FuncionariosPeer::UPDATED_AT))
    {
      $this->setUpdatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(FuncionariosPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aCidades !== null) {
				if ($this->aCidades->isModified()) {
					$affectedRows += $this->aCidades->save($con);
				}
				$this->setCidades($this->aCidades);
			}

			if ($this->aEstados !== null) {
				if ($this->aEstados->isModified()) {
					$affectedRows += $this->aEstados->save($con);
				}
				$this->setEstados($this->aEstados);
			}

			if ($this->aCredencials !== null) {
				if ($this->aCredencials->isModified()) {
					$affectedRows += $this->aCredencials->save($con);
				}
				$this->setCredencials($this->aCredencials);
			}

			if ($this->aUsuarios !== null) {
				if ($this->aUsuarios->isModified()) {
					$affectedRows += $this->aUsuarios->save($con);
				}
				$this->setUsuarios($this->aUsuarios);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = FuncionariosPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += FuncionariosPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			if ($this->collCobradorss !== null) {
				foreach($this->collCobradorss as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collUsuarioss !== null) {
				foreach($this->collUsuarioss as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aCidades !== null) {
				if (!$this->aCidades->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aCidades->getValidationFailures());
				}
			}

			if ($this->aEstados !== null) {
				if (!$this->aEstados->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aEstados->getValidationFailures());
				}
			}

			if ($this->aCredencials !== null) {
				if (!$this->aCredencials->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aCredencials->getValidationFailures());
				}
			}

			if ($this->aUsuarios !== null) {
				if (!$this->aUsuarios->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aUsuarios->getValidationFailures());
				}
			}


			if (($retval = FuncionariosPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collCobradorss !== null) {
					foreach($this->collCobradorss as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collUsuarioss !== null) {
					foreach($this->collUsuarioss as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = FuncionariosPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getNome();
				break;
			case 2:
				return $this->getEndereco();
				break;
			case 3:
				return $this->getNum();
				break;
			case 4:
				return $this->getCompl();
				break;
			case 5:
				return $this->getBairro();
				break;
			case 6:
				return $this->getCidadeId();
				break;
			case 7:
				return $this->getEstadoId();
				break;
			case 8:
				return $this->getCep();
				break;
			case 9:
				return $this->getTelRes();
				break;
			case 10:
				return $this->getTelCom();
				break;
			case 11:
				return $this->getTelCel();
				break;
			case 12:
				return $this->getEmail();
				break;
			case 13:
				return $this->getRg();
				break;
			case 14:
				return $this->getCpf();
				break;
			case 15:
				return $this->getCredencialId();
				break;
			case 16:
				return $this->getAtivo();
				break;
			case 17:
				return $this->getCreatedAt();
				break;
			case 18:
				return $this->getUpdatedAt();
				break;
			case 19:
				return $this->getUsuarioId();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = FuncionariosPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getNome(),
			$keys[2] => $this->getEndereco(),
			$keys[3] => $this->getNum(),
			$keys[4] => $this->getCompl(),
			$keys[5] => $this->getBairro(),
			$keys[6] => $this->getCidadeId(),
			$keys[7] => $this->getEstadoId(),
			$keys[8] => $this->getCep(),
			$keys[9] => $this->getTelRes(),
			$keys[10] => $this->getTelCom(),
			$keys[11] => $this->getTelCel(),
			$keys[12] => $this->getEmail(),
			$keys[13] => $this->getRg(),
			$keys[14] => $this->getCpf(),
			$keys[15] => $this->getCredencialId(),
			$keys[16] => $this->getAtivo(),
			$keys[17] => $this->getCreatedAt(),
			$keys[18] => $this->getUpdatedAt(),
			$keys[19] => $this->getUsuarioId(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = FuncionariosPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setNome($value);
				break;
			case 2:
				$this->setEndereco($value);
				break;
			case 3:
				$this->setNum($value);
				break;
			case 4:
				$this->setCompl($value);
				break;
			case 5:
				$this->setBairro($value);
				break;
			case 6:
				$this->setCidadeId($value);
				break;
			case 7:
				$this->setEstadoId($value);
				break;
			case 8:
				$this->setCep($value);
				break;
			case 9:
				$this->setTelRes($value);
				break;
			case 10:
				$this->setTelCom($value);
				break;
			case 11:
				$this->setTelCel($value);
				break;
			case 12:
				$this->setEmail($value);
				break;
			case 13:
				$this->setRg($value);
				break;
			case 14:
				$this->setCpf($value);
				break;
			case 15:
				$this->setCredencialId($value);
				break;
			case 16:
				$this->setAtivo($value);
				break;
			case 17:
				$this->setCreatedAt($value);
				break;
			case 18:
				$this->setUpdatedAt($value);
				break;
			case 19:
				$this->setUsuarioId($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = FuncionariosPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setNome($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setEndereco($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setNum($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setCompl($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setBairro($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setCidadeId($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setEstadoId($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCep($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setTelRes($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setTelCom($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setTelCel($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setEmail($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setRg($arr[$keys[13]]);
		if (array_key_exists($keys[14], $arr)) $this->setCpf($arr[$keys[14]]);
		if (array_key_exists($keys[15], $arr)) $this->setCredencialId($arr[$keys[15]]);
		if (array_key_exists($keys[16], $arr)) $this->setAtivo($arr[$keys[16]]);
		if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]);
		if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]);
		if (array_key_exists($keys[19], $arr)) $this->setUsuarioId($arr[$keys[19]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(FuncionariosPeer::DATABASE_NAME);

		if ($this->isColumnModified(FuncionariosPeer::ID)) $criteria->add(FuncionariosPeer::ID, $this->id);
		if ($this->isColumnModified(FuncionariosPeer::NOME)) $criteria->add(FuncionariosPeer::NOME, $this->nome);
		if ($this->isColumnModified(FuncionariosPeer::ENDERECO)) $criteria->add(FuncionariosPeer::ENDERECO, $this->endereco);
		if ($this->isColumnModified(FuncionariosPeer::NUM)) $criteria->add(FuncionariosPeer::NUM, $this->num);
		if ($this->isColumnModified(FuncionariosPeer::COMPL)) $criteria->add(FuncionariosPeer::COMPL, $this->compl);
		if ($this->isColumnModified(FuncionariosPeer::BAIRRO)) $criteria->add(FuncionariosPeer::BAIRRO, $this->bairro);
		if ($this->isColumnModified(FuncionariosPeer::CIDADE_ID)) $criteria->add(FuncionariosPeer::CIDADE_ID, $this->cidade_id);
		if ($this->isColumnModified(FuncionariosPeer::ESTADO_ID)) $criteria->add(FuncionariosPeer::ESTADO_ID, $this->estado_id);
		if ($this->isColumnModified(FuncionariosPeer::CEP)) $criteria->add(FuncionariosPeer::CEP, $this->cep);
		if ($this->isColumnModified(FuncionariosPeer::TEL_RES)) $criteria->add(FuncionariosPeer::TEL_RES, $this->tel_res);
		if ($this->isColumnModified(FuncionariosPeer::TEL_COM)) $criteria->add(FuncionariosPeer::TEL_COM, $this->tel_com);
		if ($this->isColumnModified(FuncionariosPeer::TEL_CEL)) $criteria->add(FuncionariosPeer::TEL_CEL, $this->tel_cel);
		if ($this->isColumnModified(FuncionariosPeer::EMAIL)) $criteria->add(FuncionariosPeer::EMAIL, $this->email);
		if ($this->isColumnModified(FuncionariosPeer::RG)) $criteria->add(FuncionariosPeer::RG, $this->rg);
		if ($this->isColumnModified(FuncionariosPeer::CPF)) $criteria->add(FuncionariosPeer::CPF, $this->cpf);
		if ($this->isColumnModified(FuncionariosPeer::CREDENCIAL_ID)) $criteria->add(FuncionariosPeer::CREDENCIAL_ID, $this->credencial_id);
		if ($this->isColumnModified(FuncionariosPeer::ATIVO)) $criteria->add(FuncionariosPeer::ATIVO, $this->ativo);
		if ($this->isColumnModified(FuncionariosPeer::CREATED_AT)) $criteria->add(FuncionariosPeer::CREATED_AT, $this->created_at);
		if ($this->isColumnModified(FuncionariosPeer::UPDATED_AT)) $criteria->add(FuncionariosPeer::UPDATED_AT, $this->updated_at);
		if ($this->isColumnModified(FuncionariosPeer::USUARIO_ID)) $criteria->add(FuncionariosPeer::USUARIO_ID, $this->usuario_id);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(FuncionariosPeer::DATABASE_NAME);

		$criteria->add(FuncionariosPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setNome($this->nome);

		$copyObj->setEndereco($this->endereco);

		$copyObj->setNum($this->num);

		$copyObj->setCompl($this->compl);

		$copyObj->setBairro($this->bairro);

		$copyObj->setCidadeId($this->cidade_id);

		$copyObj->setEstadoId($this->estado_id);

		$copyObj->setCep($this->cep);

		$copyObj->setTelRes($this->tel_res);

		$copyObj->setTelCom($this->tel_com);

		$copyObj->setTelCel($this->tel_cel);

		$copyObj->setEmail($this->email);

		$copyObj->setRg($this->rg);

		$copyObj->setCpf($this->cpf);

		$copyObj->setCredencialId($this->credencial_id);

		$copyObj->setAtivo($this->ativo);

		$copyObj->setCreatedAt($this->created_at);

		$copyObj->setUpdatedAt($this->updated_at);

		$copyObj->setUsuarioId($this->usuario_id);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach($this->getCobradorss() as $relObj) {
				$copyObj->addCobradors($relObj->copy($deepCopy));
			}

			foreach($this->getUsuarioss() as $relObj) {
				$copyObj->addUsuarios($relObj->copy($deepCopy));
			}

		} 

		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new FuncionariosPeer();
		}
		return self::$peer;
	}

	
	public function setCidades($v)
	{


		if ($v === null) {
			$this->setCidadeId('null');
		} else {
			$this->setCidadeId($v->getId());
		}


		$this->aCidades = $v;
	}


	
	public function getCidades($con = null)
	{
				include_once 'lib/model/om/BaseCidadesPeer.php';

		if ($this->aCidades === null && ($this->cidade_id !== null)) {

			$this->aCidades = CidadesPeer::retrieveByPK($this->cidade_id, $con);

			
		}
		return $this->aCidades;
	}

	
	public function setEstados($v)
	{


		if ($v === null) {
			$this->setEstadoId('null');
		} else {
			$this->setEstadoId($v->getId());
		}


		$this->aEstados = $v;
	}


	
	public function getEstados($con = null)
	{
				include_once 'lib/model/om/BaseEstadosPeer.php';

		if ($this->aEstados === null && ($this->estado_id !== null)) {

			$this->aEstados = EstadosPeer::retrieveByPK($this->estado_id, $con);

			
		}
		return $this->aEstados;
	}

	
	public function setCredencials($v)
	{


		if ($v === null) {
			$this->setCredencialId('null');
		} else {
			$this->setCredencialId($v->getId());
		}


		$this->aCredencials = $v;
	}


	
	public function getCredencials($con = null)
	{
				include_once 'lib/model/om/BaseCredencialsPeer.php';

		if ($this->aCredencials === null && ($this->credencial_id !== null)) {

			$this->aCredencials = CredencialsPeer::retrieveByPK($this->credencial_id, $con);

			
		}
		return $this->aCredencials;
	}

	
	public function setUsuarios($v)
	{


		if ($v === null) {
			$this->setUsuarioId(NULL);
		} else {
			$this->setUsuarioId($v->getId());
		}


		$this->aUsuarios = $v;
	}


	
	public function getUsuarios($con = null)
	{
				include_once 'lib/model/om/BaseUsuariosPeer.php';

		if ($this->aUsuarios === null && ($this->usuario_id !== null)) {

			$this->aUsuarios = UsuariosPeer::retrieveByPK($this->usuario_id, $con);

			
		}
		return $this->aUsuarios;
	}

	
	public function initCobradorss()
	{
		if ($this->collCobradorss === null) {
			$this->collCobradorss = array();
		}
	}

	
	public function getCobradorss($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseCobradorsPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collCobradorss === null) {
			if ($this->isNew()) {
			   $this->collCobradorss = array();
			} else {

				$criteria->add(CobradorsPeer::FUNCIONARIO_ID, $this->getId());

				CobradorsPeer::addSelectColumns($criteria);
				$this->collCobradorss = CobradorsPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(CobradorsPeer::FUNCIONARIO_ID, $this->getId());

				CobradorsPeer::addSelectColumns($criteria);
				if (!isset($this->lastCobradorsCriteria) || !$this->lastCobradorsCriteria->equals($criteria)) {
					$this->collCobradorss = CobradorsPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastCobradorsCriteria = $criteria;
		return $this->collCobradorss;
	}

	
	public function countCobradorss($criteria = null, $distinct = false, $con = null)
	{
				include_once 'lib/model/om/BaseCobradorsPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(CobradorsPeer::FUNCIONARIO_ID, $this->getId());

		return CobradorsPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addCobradors(Cobradors $l)
	{
		$this->collCobradorss[] = $l;
		$l->setFuncionarios($this);
	}


	
	public function getCobradorssJoinUsuarios($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseCobradorsPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collCobradorss === null) {
			if ($this->isNew()) {
				$this->collCobradorss = array();
			} else {

				$criteria->add(CobradorsPeer::FUNCIONARIO_ID, $this->getId());

				$this->collCobradorss = CobradorsPeer::doSelectJoinUsuarios($criteria, $con);
			}
		} else {
									
			$criteria->add(CobradorsPeer::FUNCIONARIO_ID, $this->getId());

			if (!isset($this->lastCobradorsCriteria) || !$this->lastCobradorsCriteria->equals($criteria)) {
				$this->collCobradorss = CobradorsPeer::doSelectJoinUsuarios($criteria, $con);
			}
		}
		$this->lastCobradorsCriteria = $criteria;

		return $this->collCobradorss;
	}

	
	public function initUsuarioss()
	{
		if ($this->collUsuarioss === null) {
			$this->collUsuarioss = array();
		}
	}

	
	public function getUsuarioss($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseUsuariosPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collUsuarioss === null) {
			if ($this->isNew()) {
			   $this->collUsuarioss = array();
			} else {

				$criteria->add(UsuariosPeer::FUNCIONARIO_ID, $this->getId());

				UsuariosPeer::addSelectColumns($criteria);
				$this->collUsuarioss = UsuariosPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(UsuariosPeer::FUNCIONARIO_ID, $this->getId());

				UsuariosPeer::addSelectColumns($criteria);
				if (!isset($this->lastUsuariosCriteria) || !$this->lastUsuariosCriteria->equals($criteria)) {
					$this->collUsuarioss = UsuariosPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastUsuariosCriteria = $criteria;
		return $this->collUsuarioss;
	}

	
	public function countUsuarioss($criteria = null, $distinct = false, $con = null)
	{
				include_once 'lib/model/om/BaseUsuariosPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(UsuariosPeer::FUNCIONARIO_ID, $this->getId());

		return UsuariosPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addUsuarios(Usuarios $l)
	{
		$this->collUsuarioss[] = $l;
		$l->setFuncionarios($this);
	}

   public function __toString() {
		// 
		return $this->getNome();
	}

} 